﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace mebc3
{
    [TestFixture]
    public class BoardWeaving
    {
        [Test]
        public void Weave_a_board()
        {
            var inputPin = new Pin<string>("(");
            var part = new Part();
            var outputPin = new Pin<string>(")");

            inputPin.Out += part.Process;
            part.Result += outputPin.In;

            string result = "";
            outputPin.Out += _ => result = _;
            inputPin.In("a");

            Assert.AreEqual("ax", result);
        }

    }

    public class Part
    {
        public void Process(string input)
        {
            Result(input + "x");
        }

        public event Action<string> Result;
    }


    public class Pin<T>
    {
        public string PinName;

        public Pin(string pinName)
        {
            this.PinName = pinName;
        }


        public void In(T input)
        {
            this.Out(input);
        }

        public event Action<T> Out;
    }
}
